package com.booth.base.model;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
/***
 * @TypeName：GroupsModules
 * @description：
 * @author：Administrator
 */
public class GroupsModules extends Model<GroupsModules>
{
	private static final long		serialVersionUID	= 1L;
	public static final GroupsModules	dao			= new GroupsModules();

	public static List<Integer> findByGroupsId( int gid )
	{
		List		arr	= new ArrayList();
		List		lst	= dao.find( "SELECT modules_id FROM groups_modules WHERE group_id=?", new Object[] { Integer.valueOf( gid ) } );
		Iterator	it	= lst.iterator();
		while ( it.hasNext() )
		{
			arr.add( ( (GroupsModules) it.next() ).getInt( "modules_id" ) );
		}
		return(arr);
	}


	public static void deleteByGroupsId( int gid )
	{
		Db.update( "DELETE FROM groups_modules WHERE group_id=?", new Object[] { Integer.valueOf( gid ) } );
	}


	public static void deleteByModulesId( int mid )
	{
		Db.update( "DELETE FROM groups_modules WHERE modules_id=?", new Object[] { Integer.valueOf( mid ) } );
	}
}